﻿(function () {
    BalloonShooter.Utils = {
        List: function () {
            return {
                hasValue: function (obj) {
                    return (((typeof (obj) == 'undefined') || (obj == null)) == false);
                },
                items: [],
                item: function (index, obj) {
                    if (this.hasValue(obj))
                        this.items[index] = obj;
                    else
                        return this.items[index];
                },                            
                add: function (obj) {
                    this.items[this.items.length] = obj;
                },                
                isEqual: function (a, b) {
                    return (a === b);
                },               
                clear: function () {
                    this.items = [];
                },
                remove: function (obj) {
                    var tmp = [], i = 0, j = 0;
                    for (i = 0; i < this.items.length; i++) {
                        if (!this.isEqual(this.items[i], obj)) {
                            tmp[j++] = this.items[i];
                        };
                    };
                    this.clear();
                    this.items = tmp;
                },
                removeAt: function (index) {
                    this.remove(this.items[index]);
                }
            };
        }
    };
})();